package com.fiberhome.ztelauncher.core.page.type;

import android.content.Context;
import android.view.View;

import com.fiberhome.ztelauncher.R;
import com.fiberhome.ztelauncher.core.page.holder.AdbannerViewHolder;
import com.fiberhome.ztelauncher.core.page.holder.AppViewHolder;
import com.fiberhome.ztelauncher.core.page.holder.BaseViewHolder;
import com.fiberhome.ztelauncher.core.page.holder.CustomViewHolder;
import com.fiberhome.ztelauncher.core.page.holder.ImageViewHolder;
import com.fiberhome.ztelauncher.core.page.holder.ListViewHolder;
import com.fiberhome.ztelauncher.core.page.holder.RecommendViewHolder;
import com.fiberhome.ztelauncher.core.page.holder.VideoViewHolder;
import com.fiberhome.ztelauncher.core.page.holder.WidgetViewHolder;
import com.fiberhome.ztelauncher.core.page.model.AdBannerType;
import com.fiberhome.ztelauncher.core.page.model.AppType;
import com.fiberhome.ztelauncher.core.page.model.CustomType;
import com.fiberhome.ztelauncher.core.page.model.ImageType;
import com.fiberhome.ztelauncher.core.page.model.ListType;
import com.fiberhome.ztelauncher.core.page.model.RecommendType;
import com.fiberhome.ztelauncher.core.page.model.VideoType;
import com.fiberhome.ztelauncher.core.page.model.WidgetType;
import com.fiberhome.ztelauncher.core.page.SwitchAnimView;


/**
 * Created by yq05481 on 2016/12/30.
 */

public class TypeFactoryForList implements TypeFactory {
    private final static int TYPE_RESOURCE_IMAGE = R.layout.item_image;
    private final static int TYPE_RESOURCE_VIDEO = R.layout.item_image;
    private final static int TYPE_RESOURCE_LIST = R.layout.item_image;
    private final static int TYPE_RESOURCE_WIDGET = R.layout.item_image;
    private final static int TYPE_RESOURCE_CUSTOM = R.layout.item_image;
    private final static int TYPE_RESOURCE_ADBANNER = R.layout.item_image;
    private final static int TYPE_RESOURCE_RECOMMEND = R.layout.item_image;
    private final static int TYPE_RESOURCE_APP = R.layout.item_app;

    @Override
    public int type(ImageType imageType) {
        return TYPE_RESOURCE_IMAGE;
    }

    @Override
    public int type(VideoType videoType) {
        return TYPE_RESOURCE_VIDEO;
    }

    @Override
    public int type(ListType listType) {
        return TYPE_RESOURCE_LIST;
    }

    @Override
    public int type(WidgetType widgetType) {
        return TYPE_RESOURCE_WIDGET;
    }

    @Override
    public int type(CustomType customType) {
        return TYPE_RESOURCE_CUSTOM;
    }

    @Override
    public int type(AdBannerType bannerType) {
        return TYPE_RESOURCE_ADBANNER;
    }

    @Override
    public int type(RecommendType recommendType) {
        return TYPE_RESOURCE_RECOMMEND;
    }

    @Override
    public int type(AppType appType) {
        return TYPE_RESOURCE_APP;
    }

    @Override
    public BaseViewHolder createViewHolder(int type, View itemView) {

        if (TYPE_RESOURCE_IMAGE == type) {
            return new ImageViewHolder(itemView);

        } else if (TYPE_RESOURCE_VIDEO == type) {
            return new VideoViewHolder(itemView);

        } else if (TYPE_RESOURCE_LIST == type) {
            return new ListViewHolder(itemView);

        } else if (TYPE_RESOURCE_WIDGET == type) {
            return new WidgetViewHolder(itemView);

        } else if (TYPE_RESOURCE_CUSTOM == type) {
            return new CustomViewHolder(itemView);

        } else if (TYPE_RESOURCE_ADBANNER == type) {
            return new AdbannerViewHolder(itemView);

        } else if (TYPE_RESOURCE_RECOMMEND == type) {
            return new RecommendViewHolder(itemView);

        } else if (TYPE_RESOURCE_APP == type) {
            return new AppViewHolder(itemView);

        }
        return new ImageViewHolder(itemView);
    }

    public static View getView(Context context,int type){
        if (TYPE_RESOURCE_IMAGE == type) {
            return new SwitchAnimView(context);

        } else if (TYPE_RESOURCE_VIDEO == type) {
            return new SwitchAnimView(context);

        } else if (TYPE_RESOURCE_LIST == type) {
            return new SwitchAnimView(context);

        } else if (TYPE_RESOURCE_WIDGET == type) {
            return new SwitchAnimView(context);

        } else if (TYPE_RESOURCE_CUSTOM == type) {
            return new SwitchAnimView(context);

        } else if (TYPE_RESOURCE_ADBANNER == type) {
            return new SwitchAnimView(context);

        } else if (TYPE_RESOURCE_RECOMMEND == type) {
            return new SwitchAnimView(context);

        } else if (TYPE_RESOURCE_APP == type) {
            return new SwitchAnimView(context);
        }
        return new SwitchAnimView(context);
    }
}
